Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

feat(expo-cli): add shortcut to open editor #1879

Merged
merged 4 commits into from
Apr 14, 2020

Conversation

byCedric
Copy link
Member

Fixes #1762

This uses Sindre's env-editor and spawnAsync over some other options I've tried. The env editor basically tries to find the default editor, if that's not found it will fallback to vscode. If none of these 2 options work, it will log with an error and describes how to fix it.

I tested this on MacOS, Windows and Windows WSL 😄

Fun facts(tm)

  • open-editor didn't work that well for folders on both MacOS and Windows. On MacOS it thought it was a file and appended line and colon (/my/path:1:1) to this. On Windows there were some errors with --goto flag.
  • open didn't work on MacOS, apparently MacOS can't open vscode with open /my/path -a vscode (but does work with open /my/path -a "Visual Studio Code"). Also open didn't reject the first attempt, it resolved without errors.

@codecov-io
Copy link

Codecov Report

Merging #1879 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1879   +/-   ##
=======================================
  Coverage   59.95%   59.95%           
=======================================
  Files          84       84           
  Lines        2502     2502           
  Branches      687      694    +7     
=======================================
  Hits         1500     1500           
+ Misses        979      972    -7     
- Partials       23       30    +7     
Impacted Files Coverage Δ
packages/pwa/src/Manifest.ts 37.25% <0.00%> (ø)
packages/config/src/Config.ts 58.16% <0.00%> (ø)
packages/config/src/android/Manifest.ts 69.79% <0.00%> (ø)
...ackages/webpack-config/src/addons/withDevServer.ts 33.33% <0.00%> (ø)
...es/webpack-config/src/loaders/createBabelLoader.ts 46.66% <0.00%> (ø)
...webpack-config/src/plugins/FaviconWebpackPlugin.ts 4.76% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b9b581...5ece000. Read the comment docs.

@@ -4178,11 +4178,6 @@
dependencies:
"@types/node" "*"

"@types/caseless@*":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's going on here, looks like the yarn lockfile could be slightly outdated?

@brentvatne
Copy link
Member

brentvatne commented Apr 14, 2020

we have previously used the EXPO_EDITOR env var for this, i can't remember exactly where though, i think it might have been in XDE. i'm ok with not supporting this env var anymore though.

the old script for this is here:

export async function openFileInEditorAsync(path: string) {
if (process.platform === 'darwin') {
// This will use the ENV var $EXPO_EDITOR if set, or else will try various
// popular editors, looking for one that is open, or if none are, one that is installed
return await osascript.openInEditorAsync(path, process.env.EXPO_EDITOR);
} else {
throw new XDLError('PLATFORM_NOT_SUPPORTED', 'openFileInEditorAsync not supported');
}
}

i wonder why we chose to use osascript 🤔 might be worth checking if we have any usage of this module any removing it if not

@brentvatne brentvatne merged commit 2e130d6 into expo:master Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hotkey to open code at project root in editor
3 participants